package com.fjnldx.mes.controller.environment;

import com.fjnldx.mes.domain.domainReq.MachineNumberReq;
import com.fjnldx.mes.domain.domainReq.PageRequest;
import com.fjnldx.mes.domain.domainReq.TempHumidityPageReq;
import com.fjnldx.mes.domain.domainReq.TempHumidityReq;
import com.fjnldx.mes.domain.domainRes.Result;
import com.fjnldx.mes.service.environment.EnvironmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/environment")
@Api(value = "环境管理", tags = "环境管理模块")
public class EnvironmentController {

    @Resource
    private EnvironmentService environmentService;

    @PostMapping("/getTempHumidityByIntegralPoint")
    @ApiOperation(value = "获取今日整点的细纱机温湿度", notes = "Api")
    public Result getTempHumidityByIntegralPoint(@RequestBody MachineNumberReq machineNumber){
        return environmentService.getTempHumidityByIntegralPoint(machineNumber.getMachineNumber());
    }

    @PostMapping("/getTempHumidityByCurrentTime")
    @ApiOperation(value = "获取细纱机最近的温湿度", notes = "Api")
    public Result getTempHumidityByCurrentTime(){
        return environmentService.getTempHumidityByCurrentTime();
    }

    @GetMapping("/getHistoryTempHumidityByPage")
    @ApiOperation(value = "获取细纱机历史的温湿度表格数据", notes = "Api")
    public Result getHistoryTempHumidityByPage(TempHumidityPageReq tempHumidityPageReq, PageRequest pageRequest){
        return environmentService.getHistoryTempHumidityByPage(tempHumidityPageReq, pageRequest);
    }

    @PostMapping("/getHistoryTempHumidity")
    @ApiOperation(value = "获取细纱机历史的温湿度折线图数据", notes = "Api")
    public Result getHistoryTempHumidity(@RequestBody TempHumidityReq tempHumidityReq){
        return environmentService.getHistoryTempHumidity(tempHumidityReq);
    }

    @PostMapping("/getTempHumidityTable")
    @ApiOperation(value = "获取温湿度表的列表", notes = "Api")
    public Result getTempHumidityTable(@RequestParam List<Integer> ct){
        return environmentService.getTempHumidityTable(ct);
    }
}
